<?php

/**
 * document_types actions.
 *
 * @package    erp-crm
 * @subpackage document_types
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class document_typesActions extends sfActions
{
  public function executeIndex(){
    $this->listDocumentTypesForm = new ListDocumentTypesForm();
    $this->listDocumentTypesList = ListDocumentTypesPeer::doSelectSortByName();
  }

  public function executeEdit($request){
    $this->listDocumentTypesForm = new ListDocumentTypesForm(ListDocumentTypesPeer::retrieveByPk($request->getParameter('iden')));
    $this->forward404Unless($this->listDocumentTypesForm);
    $this->listDocumentTypesList = ListDocumentTypesPeer::doSelectSortByName();
    $this->setTemplate('index');
  }

  public function executeInsert($request){
    $list_document_types = $request->getParameter('list_document_types');
    $list_document_types['iden'] = myStringGenerator::getIden();
    $this->listDocumentTypesForm = new ListDocumentTypesForm();
    $this->listDocumentTypesForm->bind($list_document_types);
    if($this->listDocumentTypesForm->isValid()){
      $this->listDocumentTypesForm->save();
      $this->redirect('document_types/index');
    }else{
      $this->listDocumentTypesList = ListDocumentTypesPeer::doSelectSortByName();
      $this->setTemplate('index');
    }
  }
  
  public function executeUpdate($request){
    $list_document_types = $request->getParameter('list_document_types');
    $this->listDocumentTypesForm = new ListDocumentTypesForm(ListDocumentTypesPeer::retrieveByPk($list_document_types['iden']));
    $this->forward404Unless($this->listDocumentTypesForm);
    $this->listDocumentTypesForm->bind($request->getParameter('list_document_types'));
    if($this->listDocumentTypesForm->isValid()){
      $this->listDocumentTypesForm->save();
      $this->redirect('document_types/index');
    }else{
      $this->listDocumentTypesList = ListDocumentTypesPeer::doSelectSortByName();
      $this->setTemplate('index');
    }
  }

  public function executeDelete($request){
    $listDocumentTypes = ListDocumentTypesPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($listDocumentTypes);
    $listDocumentTypes->delete();
    $this->redirect('document_types/index');
  }

}
